//
//  BSCommentCell.m
//  BaiSi
//
//  Created by Sycamore on 16/5/27.
//  Copyright © 2016年 Sycamore. All rights reserved.
//

#import "BSCommentCell.h"
#import "BSCommentItem.h"
#import "BSImageManager.h"
#import "BSUserItem.h"

@interface BSCommentCell ()

@property (weak, nonatomic) IBOutlet UIImageView *iconView;

@property (weak, nonatomic) IBOutlet UIImageView *sexView;
@property (weak, nonatomic) IBOutlet UILabel *nameView;
@property (weak, nonatomic) IBOutlet UILabel *like_count;
@property (weak, nonatomic) IBOutlet UILabel *comment;

@property (nonatomic,assign) BOOL isClick;    //记录是否点击了
@property (weak, nonatomic) IBOutlet UIButton *likeButton;

@end


@implementation BSCommentCell
- (IBAction)dingClick:(UIButton *)sender {
    
    sender.selected = !sender.selected;
    _commentItem.isClick = sender.selected;
}

- (void)awakeFromNib {
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    UIImageView *backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"mainCellBackground"]];
    self.backgroundView = backgroundView;
    self.autoresizingMask = UIViewAutoresizingNone;
}

- (void)setCommentItem:(BSCommentItem *)commentItem
{
    _commentItem = commentItem;
    
    _iconView.image = [BSImageManager setHeaderImageWithURL:[NSURL URLWithString:commentItem.userItem.profile_image] placeholder:@"defaultUserIcon" inImageView:_iconView];
    _nameView.text = commentItem.userItem.username;
    _like_count.text = commentItem.like_count;
    _comment.text = commentItem.content;
    
    //设置性别图片
    if ([commentItem.userItem.sex isEqualToString:BSSexMale]) {
        _sexView.image = [UIImage imageNamed:@"Profile_manIcon"];
        
    }else{
        _sexView.image = [UIImage imageNamed:@"Profile_womanIcon"];
    }
    
    _likeButton.selected = commentItem.isClick;
    
}
@end
